package com.exam.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.exam.pojo.Teacher;
import org.apache.ibatis.annotations.*;

public interface TeacherMapper extends BaseMapper<Teacher> {

@Select("select * from teacher")
    IPage<Teacher> findTeacherAll(Page<Teacher> teacherPage);
//@Insert("insert into teacher(teacherId,teacherName,institute,sex,tel,email,pwd,carId,type,role) " +
//        "value(null,#{teacherName},#{institute},#{sex},#{tel},#{email},#{pwd},#{carId},#{type},#{role})")

    //@Options(useGeneratedKeys = true,keyProperty = "teacherId")
//    @Insert("insert into teacher(teacherName,sex,tel,email,pwd,cardId,role,type,institute) " +
//            "values(#{teacherName},#{sex},#{tel},#{email},#{pwd},#{cardId},#{role},#{type},#{institute})")
    @Insert("insert into teacher(teacherId,teacherName,sex,tel,email,pwd,cardId,role,type,institute) " +
            "values(null,#{teacherName},#{sex},#{tel},#{email},#{pwd},#{cardId},#{role},#{type},#{institute})")

    int add(Teacher teacher);
    @Select("select * from teacher where teacherId = #{teacherId}")
    Object findTeacherById(Integer teacherId);
    @Delete("delete from teacher where teacherId = #{teacherId}")
    Object deleteTeacherById(Integer teacherId);
    @Update("update teacher set teacherName = #{teacherName},sex = #{sex}," +
            "tel = #{tel}, email = #{email},pwd = #{pwd},cardId = #{cardId}," +
            "role = #{role},institute = #{institute},type = #{type} where teacherId = #{teacherId}")
    Object updateTeacher(Teacher teacher);
}
